VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "DebugNotifier"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit

Private hasFailed As Boolean
Private mProject As ProjectFixture
Private mClass As ClassFixture
Private mMethod As MethodFixture
Private mTotalAssertCount As Integer
Private mClassAssertCount As Integer
Private mPrintedClass As Boolean
Private mPrintedMethod As Boolean

Public Sub StartProject(project As ProjectFixture)
Set mProject = project
Debug.Print
Debug.Print project.name, "Classes="; project.numOfClasses, "Methods="; project.numOfMethods  ', "Asserts="; project.NumOfAsserts
End Sub
Public Sub StartClass(Class As ClassFixture)
Set mClass = Class
mClassAssertCount = 0
mPrintedClass = False
End Sub

Public Sub StartMethod(method As MethodFixture)
Set mMethod = method
mPrintedMethod = False
End Sub

Public Sub StartFineMethod(method As FineMethodCaller)
End Sub
Private Sub countAssert()
mTotalAssertCount = mTotalAssertCount + 1
mClassAssertCount = mClassAssertCount + 1
End Sub
Public Sub testResult(result As Boolean, actual As Variant, expected As Variant, tagMessage As String, fullDescription As String)
countAssert
logResult result, actual, expected, tagMessage, fullDescription

End Sub
Public Sub logResult(result As Boolean, actual As Variant, expected As Variant, tagMessage As String, fullDescription As String)
If hasFailed Then
'    If Not result Then
'        printFailure tagMessage, fullDescription
'    End If
Else
    If result Then
        Debug.Print "*";
    Else
        hasFailed = True
        Debug.Print
        'printFailure tagMessage, fullDescription
'        If Len(tagMessage) Then Debug.Print tagMessage
'        Debug.Print fullDescription
    End If
End If
If Not result Then
    'Debug.Print tagMessage
    printFailure tagMessage, fullDescription
End If
End Sub
Private Sub printFailure(tagMessage As String, fullDescription As String)
If Not mPrintedClass Then
    Debug.Print "Class: "; mClass.name
    mPrintedClass = True
End If
If Not mPrintedMethod Then
    Debug.Print "Method: "; mMethod.name
    mPrintedMethod = True
End If
If Len(tagMessage) Then Debug.Print tagMessage
If Len(fullDescription) Then Debug.Print fullDescription
End Sub
Public Sub EndFineMethod()
End Sub

Public Sub EndMethod()
End Sub

Public Sub EndClass()
If mClassAssertCount <> mClass.NumOfAsserts Then
    logResult False, mClass.NumOfAsserts, mClassAssertCount, "Warning - assert mismatch: " + Str(mClass.NumOfAsserts) + "<>" + CStr(mClassAssertCount), ""
End If
End Sub

Public Sub EndProject()
If hasFailed Then
    Debug.Print "Failed!"
Else
    Debug.Print
    Debug.Print "Done!"
End If
Debug.Print "Asserts="; mProject.NumOfAsserts; "("; mTotalAssertCount; "counted)"
Debug.Print Format$(mProject.elapsedTime, "#0.0000 seconds")
End Sub


Private Sub Class_Initialize()
hasFailed = False
End Sub
